package com.ymatou.iapi.trading.useranalysis.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
import java.util.Random;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.useranalysis.parameter.ChangeBuyerOrderStatisticsBean;
import com.ymatou.iapi.trading.useranalysis.service.ChangeBuyerOrderStatisticsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.database.mongo.BuyerSellerOrderStatisticsMongoBean;
import com.ymttest.database.mongo.UserAnalysisMongoWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
/**
*更新订单行为统计信息接口
*FreeMaker Template自动生成代码
*/
@TestSuite
@Ignore
//接口废弃
public class Ts_ChangeBuyerOrderStatistics {
	private static ChangeBuyerOrderStatisticsBean changebuyerorderstatisticsBean;
	private static ChangeBuyerOrderStatisticsCall changebuyerorderstatisticsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新订单行为统计信息接口");
	}

	@Before
	public void caseUp() {
		changebuyerorderstatisticsBean = new ChangeBuyerOrderStatisticsBean();
		changebuyerorderstatisticsCall = new ChangeBuyerOrderStatisticsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(changebuyerorderstatisticsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private long getSellerIdByUnionId(long unionId, long buyerId) {

		return unionId - (buyerId << 32);
	}

	private long getUnionId(long buyerId, long sellerId) {

		return (buyerId << 32) + sellerId;
	}

	private void callChangeBuyerOrderStatistics(long sellerId, long userId,
			long orderId, int type) throws ClientProtocolException, IOException {

		changebuyerorderstatisticsBean.setSellerId(sellerId);
		changebuyerorderstatisticsBean.setBuyerId(userId);
		changebuyerorderstatisticsBean.setBusinessType(2);
		changebuyerorderstatisticsBean.setOrderId(orderId);
		changebuyerorderstatisticsCall.setData(changebuyerorderstatisticsBean);
		changebuyerorderstatisticsCall.callService();

	}

	/**
	 * 
	 * 新用户下单
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 * 
	 */
	public static PlaceOrderResp placeOrder() throws Exception {

		int userId = new OrderCallService().createNewUser();

		PlaceOrderReq placeorderBean = PlaceOrderService
				.getDefaultOrderReq(userId);

		return PlaceOrderService.callPlaceOrderService(placeorderBean);

	}
	private void verifyDb() {

		UserAnalysisMongoWapper buyerSellerOrderStatistics;
		try {
			buyerSellerOrderStatistics = new UserAnalysisMongoWapper();

			long userId = changebuyerorderstatisticsBean.getBuyerId();
			long sellerId = changebuyerorderstatisticsBean.getSellerId();

			long id = getUnionId(userId, sellerId);
			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.debug("buyerSellerOrderStatisticsMongoBean:"
					+ buyerSellerOrderStatisticsMongoBean);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					true, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					true, "验证hasConfirmedOrders");

		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_000() {
		Logger.start(true, "TEST");

		Logger.info(getSellerIdByUnionId(20242082, 20238699));

		Logger.info(getUnionId(20238699, 3383));

	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_001() {
		Logger.start(true, "BusinessType 14-创建订单 更新订单行为统计信息成功");
		try {

			PlaceOrderResp placeOrderResp = placeOrder();

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();

			BigDecimal price = placeOrderResp.getPayAmount();

			//new OrderCallService().orderPayRequest(userId, price, tradingId);

			changebuyerorderstatisticsBean.setSellerId(sellerId);
			changebuyerorderstatisticsBean.setBuyerId(Long.valueOf(userId));
			changebuyerorderstatisticsBean.setBusinessType(14);
			changebuyerorderstatisticsBean.setOrderId(orderId);

			changebuyerorderstatisticsCall
					.setData(changebuyerorderstatisticsBean);
			changebuyerorderstatisticsCall.callService();
			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

			Logger.verifyIsNull(
					buyerSellerOrderStatisticsMongoBean.getFirstPaidOrderId(),
					"验证FirstPaidOrderId为null");

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getSellerId(),
					sellerId, "验证sellerId");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getUserId(),
					Long.valueOf(userId), "验证userId");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_002() {

		Logger.start(true, "BusinessType 14-创建订单重复创建订单 更新订单行为统计信息成功");
		try {

			long userId = new Random().nextInt(1000000);

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));

			changebuyerorderstatisticsBean.setSellerId(sellerId);
			changebuyerorderstatisticsBean.setBuyerId(userId);
			changebuyerorderstatisticsBean.setBusinessType(14);
			changebuyerorderstatisticsBean.setOrderId(11112233L);
			changebuyerorderstatisticsCall
					.setData(changebuyerorderstatisticsBean);
			changebuyerorderstatisticsCall.callService();

			changebuyerorderstatisticsBean.setOrderId(231444552L);
			changebuyerorderstatisticsCall.callService();

			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_003() {
		Logger.start(true, "BusinessType 1-创建订单后取消订单 更新订单行为统计信息成功");
		try {
			long userId = new Random().nextInt(1000000);

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));
			changebuyerorderstatisticsBean.setSellerId(sellerId);
			changebuyerorderstatisticsBean.setBuyerId(userId);
			changebuyerorderstatisticsBean.setBusinessType(14);
			changebuyerorderstatisticsBean.setOrderId(11112233L);
			changebuyerorderstatisticsCall
					.setData(changebuyerorderstatisticsBean);
			changebuyerorderstatisticsCall.callService();

			changebuyerorderstatisticsBean.setBusinessType(1);
			changebuyerorderstatisticsCall.callService();

			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					true, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ChangeBuyerOrderStatistics_004() {
		Logger.start(true, "BusinessType 14-创建订单重复创建订单取消一单 更新订单行为统计信息成功");
		try {
			long userId = new Random().nextInt(1000000);

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));

			changebuyerorderstatisticsBean.setSellerId(sellerId);
			changebuyerorderstatisticsBean.setBuyerId(userId);
			changebuyerorderstatisticsBean.setBusinessType(14);
			changebuyerorderstatisticsBean.setOrderId(11112233L);
			changebuyerorderstatisticsCall
					.setData(changebuyerorderstatisticsBean);
			changebuyerorderstatisticsCall.callService();

			Thread.sleep(1000);
			changebuyerorderstatisticsBean.setOrderId(11111111252l);
			changebuyerorderstatisticsCall.callService();

			changebuyerorderstatisticsBean.setBusinessType(1);
			changebuyerorderstatisticsCall.callService();

			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_005() {
		Logger.start(true, "BusinessType 1-创建订单后确认收货 更新订单行为统计信息成功");
		try {
			long userId = new Random().nextInt(1000000);
			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));

			changebuyerorderstatisticsBean.setSellerId(sellerId);
			changebuyerorderstatisticsBean.setBuyerId(userId);
			changebuyerorderstatisticsBean.setBusinessType(4);
			changebuyerorderstatisticsBean.setOrderId(11112233L);
			changebuyerorderstatisticsCall
					.setData(changebuyerorderstatisticsBean);
			changebuyerorderstatisticsCall.callService();

			changebuyerorderstatisticsBean.setBusinessType(1);
			changebuyerorderstatisticsCall.callService();

			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					true, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					true, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_006() {
		Logger.start(true, "老用户 BusinessType 14-创建订单 更新订单行为统计信息成功");
		try {
			long userId = Long.valueOf(EnvSetup.getData("BuyUserId"));

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));
			changebuyerorderstatisticsBean.setSellerId(sellerId);
			changebuyerorderstatisticsBean.setBuyerId(userId);
			changebuyerorderstatisticsBean.setBusinessType(14);
			changebuyerorderstatisticsBean.setOrderId(11112233L);
			changebuyerorderstatisticsCall
					.setData(changebuyerorderstatisticsBean);
			changebuyerorderstatisticsCall.callService();
			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					true, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_007() {
		Logger.start(true, "创建订单走MQ消息总线更新订单行为统计信息成功");
		try {
			OrderCallService orderCallService = new OrderCallService();

			Map user = orderCallService.registerUser();

			Map map = orderCallService.createM2cOrder(user);

			Long orderId = ((Integer) map.get("orderId")).longValue();
			long userId = ((Integer) map.get("userId")).longValue();
			long sellerId = ((Integer) map.get("sellerId")).longValue();

			Thread.sleep(3000);
			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_008() {
		Logger.start(true, "创建2个订单,取消其中1个订单，走MQ消息总线 更新订单行为统计信息成功");
		try {
			OrderCallService orderCallService = new OrderCallService();

			Map user = orderCallService.registerUser();

			Map map = orderCallService.createM2cOrder(user);
			Map map2 = orderCallService.createM2cOrder(user);

			Long orderId = ((Integer) map.get("orderId")).longValue();
			Long userId = ((Integer) map.get("userId")).longValue();
			Long sellerId = ((Integer) map.get("sellerId")).longValue();
			Long orderId2 = ((Integer) map2.get("orderId")).longValue();

			orderCallService.cancelOrder(orderId.intValue(), userId.intValue());

			Thread.sleep(3000);
			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_009() {
		Logger.start(true, "创建2个订单,取消2个订单，走MQ消息总线 更新订单行为统计信息成功");
		try {
			OrderCallService orderCallService = new OrderCallService();

			Map user = orderCallService.registerUser();

			Map map = orderCallService.createM2cOrder(user);
			Map map2 = orderCallService.createM2cOrder(user);

			Long orderId = ((Integer) map.get("orderId")).longValue();
			Long userId = ((Integer) map.get("userId")).longValue();
			Long sellerId = ((Integer) map.get("sellerId")).longValue();
			Long orderId2 = ((Integer) map2.get("orderId")).longValue();

			orderCallService.cancelOrder(orderId.intValue(), userId.intValue());
			orderCallService
					.cancelOrder(orderId2.intValue(), userId.intValue());

			Thread.sleep(5000);
			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					true, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_010() {
		Logger.start(true, "订单确认收货走MQ消息总线更新订单行为统计信息成功");
		try {
			OrderCallService orderCallService = new OrderCallService();

			Map user = orderCallService.registerUser();

			Map map = orderCallService.createM2cOrder(user);

			Long orderId = ((Integer) map.get("orderId")).longValue();
			Long tradingId = ((Integer) map.get("tradingId")).longValue();
			Long userId = ((Integer) map.get("userId")).longValue();
			Long sellerId = ((Integer) map.get("sellerId")).longValue();

			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId.intValue());
			// 支付订单
			orderCallService.orderPayRequest(userId.intValue(), totalPrice,
					tradingId.intValue());
			// 接单
			orderCallService.acceptOrder(orderId.intValue(),
					sellerId.intValue());
			// 商家发货
			orderCallService
					.dispatched(orderId.intValue(), sellerId.intValue());
			//确认收货
			orderCallService.confirmReceive(userId.intValue(),
					orderId.intValue());

			Thread.sleep(5000);
			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();
			long id = getUnionId(userId, sellerId);

			Logger.comment("校验sellerid为:" + sellerId);
			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					true, "验证hasConfirmedOrders");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_011() {
		Logger.start(true, "BusinessType 2-新用户下单支付 更新订单行为统计信息成功");
		try {

			PlaceOrderResp placeOrderResp = placeOrder();

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int tradingId = placeOrderResp.getTradingId();
			int userId = placeOrderResp.getUserId();

			BigDecimal price = placeOrderResp.getPayAmount();
			//支付
			new OrderCallService().orderPayRequest(userId, price, tradingId);

			callChangeBuyerOrderStatistics(sellerId, userId, orderId, 2);

			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();

			long id = getUnionId(userId, sellerId);

			Logger.comment("id为:" + id);

			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					false, "验证noOrdersOrAllCancelled");
			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

			Logger.info("firstPaidTime"
					+ YMTDateUtil.getFormatTime(
							buyerSellerOrderStatisticsMongoBean
									.getFirstPaidTime(),
							YMTDateUtil.YMDTHMS_STRING));

			DataUtil.verifyDateEquals(
					buyerSellerOrderStatisticsMongoBean.getFirstPaidTime(),
					new Date(), "验证FirstPaidTime 时间");

			Logger.verifyEquals(orderId,
					buyerSellerOrderStatisticsMongoBean.getFirstPaidOrderId(),
					"校验首单支付订单号");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChangeBuyerOrderStatistics_012() {
		Logger.start(true, "BusinessType 2-新用户下单支付后,取消订单  更新订单行为统计信息成功");
		try {

			PlaceOrderResp placeOrderResp = placeOrder();

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int tradingId = placeOrderResp.getTradingId();
			int userId = placeOrderResp.getUserId();

			BigDecimal price = placeOrderResp.getPayAmount();
			//支付
			new OrderCallService().orderPayRequest(userId, price, tradingId);

			callChangeBuyerOrderStatistics(sellerId, userId, orderId, 2);

			new OrderCallService().cancelOrder(orderId, userId);

			callChangeBuyerOrderStatistics(sellerId, userId, orderId, 1);

			UserAnalysisMongoWapper buyerSellerOrderStatistics = new UserAnalysisMongoWapper();

			long id = getUnionId(userId, sellerId);

			Logger.comment("id为:" + id);

			BuyerSellerOrderStatisticsMongoBean buyerSellerOrderStatisticsMongoBean = buyerSellerOrderStatistics
					.findById(id);

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getNoneOrAllCancelled(),
					true, "验证noOrdersOrAllCancelled");

			Logger.verifyEquals(
					buyerSellerOrderStatisticsMongoBean.getAnyConfirmed(),
					null, "验证hasConfirmedOrders");

			Logger.info("firstPaidTime"
					+ buyerSellerOrderStatisticsMongoBean.getFirstPaidTime());

			Logger.verifyIsNull(
					buyerSellerOrderStatisticsMongoBean.getFirstPaidTime(),
					"校验首单支付时间为空");

			Logger.verifyIsNull(
					buyerSellerOrderStatisticsMongoBean.getFirstPaidOrderId(),
					"校验首单支付订单为空");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}